/* $Id: Diet3DMIDlet.java.in,v 1.6 2009-01-12 09:46:33 rzr Exp $ */
#ifndef Diet3DMIDlet_java_in_
#define Diet3DMIDlet_java_in_

#include "HackJavaCpp.java.in"
//#define SINGLE
/**
 * @author www.Philippe.COVAL.free.fr
 * Copyright and License : http://rzr.online.fr/license.htm
 **/
final public class Diet3DMIDlet
    extends MIDlet
    implements CommandListener 
{
    Display mDisplay = null ;
    Command mExitCommand = null ;
    Command cmd = null;

    Diet3DCanvas mCanvas = new Diet3DCanvas();

    Form fmMain = null;
    String msg="Diet3D\n (c) \nwww.rzr.free.fr\nPress Keys to toggle rendermode, shapes etc\n";
    StringItem tbAction = null;
    
    boolean started = false;

    ChoiceGroup lrender = null;
    ChoiceGroup lshape = null;
    ChoiceGroup lanim = null;

    //String onoff[] = { "off", "on" };
    
    public void info()
    {
        mCanvas.stop();
        mDisplay.setCurrent( fmMain );
    }

    public void startApp() 
    {
        mDisplay = Display.getDisplay(this);
        mCanvas.mDisplay = mDisplay;

        fmMain = new Form("www.rzr.free.fr");
        
        //msg += System.getProperty("microedition.profiles" ); //crash uemu
        //fmMain.append( msg );

#if 0 //ndef INCLUDE_Diet3D

        lanim = new ChoiceGroup
	    ( "Animation :", Choice.EXCLUSIVE, mCanvas.mRender.vanim, null);
        fmMain.append( lanim ); 

        lshape = new ChoiceGroup
	    ( "Choose Shape :", Choice.EXCLUSIVE, mCanvas.mRender.vshape, null);
        fmMain.append( lshape); 

        lrender = new ChoiceGroup
	    ( "Choose Rendering mode :"
	      , Choice.EXCLUSIVE, mCanvas.mRender.vmode, null);
        fmMain.append( lrender); 
#endif
        //--
        mExitCommand = new Command("Exit", Command.EXIT, 0);
        cmd = new Command("[Menu/Back]", Command.SCREEN, 2);        
        
        fmMain.addCommand(mExitCommand);
        fmMain.addCommand(cmd);
        fmMain.setCommandListener(this);
        
        mCanvas.addCommand(mExitCommand);
        mCanvas.addCommand(cmd);
        mCanvas.setCommandListener(this);

        mCanvas.start();
        mDisplay.setCurrent(mCanvas);
    }
    
    
    public void pauseApp() 
    {
    }
    
    public void destroyApp(boolean unconditional) 
    {
        info();
    }

    public void exit()
    {
        mCanvas.stop();
        pauseApp();
        destroyApp( true );
        notifyDestroyed();
    }
  
    public void commandAction(Command c, Displayable s) 
    {
        if (c.getCommandType() == Command.EXIT) {
            exit();
        } else { //if ( c == "" ) {

          #if 0 // ndef CONFIG_SUPPORT_API_NET_RIM
            mCanvas.mRender.toggleAnim( lanim.getSelectedIndex() );
            mCanvas.mRender.toggleShape( lshape.getSelectedIndex() );
            mCanvas.mRender.toggleMode( lrender.getSelectedIndex() );
#endif
            //Form waitForm = new Form("Waiting...");
            //mDisplay.setCurrent(waitForm);
            //mCanvas.start();
            if ( mCanvas.isStarted_ == true) {
                mCanvas.stop(); 
                info(); 
            }
            else {
                mCanvas.start(); 
                mDisplay.setCurrent(mCanvas); 
            }
        }
    }
}

#endif
//#eof "$Id: Diet3DMIDlet.java.in,v 1.6 2009-01-12 09:46:33 rzr Exp $"
